package top.zuli.package01.class15;

import org.junit.Test;

public class Demo4 {
    @Test
    public void StringMethodTest4() {
        String str = "胖叔讲java,胖叔讲java";
        //替换字符串
        System.out.println(str.replace("java","JAVA"));
        //根据正则表达式替换所有符合规则的内容，正则表达式先用，后面详细讲解
        //[a-z]+ 正则表达式含义匹配a-z的字母出现一次或多次
        System.out.println(str.replaceAll("[a-z]+","pangshu"));
        //根据正则表达式替换第一个符合规则的内容，正则表达式先用，后面详细讲解
        System.out.println(str.replaceFirst("[a-z]+", "pangshu"));
    }
}

/*
public class Demo4 {
    @Test
    public void StringMethodTest4(){
        String str = "祖力皮喀尔and阿丽米热";
        System.out.println(str.replace("力","丽"));
        System.out.println(str.replaceAll("[a-z]+","zulpikar"));
        System.out.println(str.replaceFirst("[a-z]+","almira"));
    }
}
*/

/*
public class Demo4 {
    @Test
    public void StringMethodTest4(){
        String str = "祖丽皮喀尔and阿丽米热loveEachOther";
        System.out.println(str.replace("and","特别爱"));
        System.out.println(str.replaceAll("丽","力"));
        System.out.println(str.replaceFirst("丽","力"));
        System.out.println(str.replaceAll("[a-z]+","love"));
        System.out.println(str.replaceFirst("[a-z]+","love"));
    }
}
*/
